#include <iostream>
using namespace std;

signed main() {
    int n;
    cin >> n;
    string s1, s2, ans;
    getline(cin, s1);
    getline(cin, s1);
    ans = s1;
    for (int i = 1; i < n; i++) {
        getline(cin, s2);
        string t;
        int p = s1.size() - 1, q = s2.size() - 1;
        while (p >= 0 && q >= 0) {
            if (s1[p] == s2[q])    t.append(1, s1[p]);
            else    break;
            p--;
            q--;
        }
        s1 = s2;
        if (t.size() < ans.size())    ans = t;
    }
    if (ans.size()) {
        int i = ans.size() - 1;
        // if (ans[i] == ' ')    i--; // pta中要加这一行，牛客网中不用
        for (; i >= 0; i--)    cout << ans[i];
    } else    cout << "nai";
    return 0;
}